package service

import (
	"context"
	"ginfwk/domain/model/entity"
	"ginfwk/domain/repository"
	"ginfwk/framework/base"
	di "github.com/samber/do"
)

type UserService struct {
	base.Context

	UserRepository repository.UserRepository
}

func (s *UserService) InitContext(ctx context.Context) {
	// 上下文初始化
	s.Context.InitContext(ctx)

	// 仓储层实例化
	s.UserRepository = di.MustInvoke[repository.UserRepositoryMaker](nil)()
	s.UserRepository.InitContext(ctx)
}

func (s *UserService) GetUserInfo(id int) *entity.UserEntity {
	return s.UserRepository.GetUserInfo(id)
}

func (s *UserService) GetUserList(ids []int) []*entity.UserEntity {
	return s.UserRepository.GetUserList(ids)
}
